#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, k;
string s;
// 加入 每一段的最大值是x ，能不能切割成k段
bool judge(ll x) {
  ll res = 0;
  ll zero = 0, one = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0')
      zero++;
    else
      one++;

    if (zero * one > x) {
      res++;
      if (s[i] == '0') {
        zero = 1;
        one = 0;
      } else {
        one = 1;
        zero = 0;
      }
    }
  }
  res++;
  return res <= k;
}
int main() {

  cin >> n >> k;

  cin >> s;

  ll zero = 0;
  ll ones = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      zero++;
    } else {
      ones++;
    }
  }
  ll left = 0, right = zero * ones;
  ll ans = 0;
  while (left <= right) {
    ll mid = (left + right) / 2;
    if (judge(mid)) {  // 如果能切割
      ans = mid;       // 记下当前得分方案
      right = mid - 1; // 尝试在左边找一找，有没有更有方案
    } else {
      left = mid + 1; // 左边找不到，只能在右边找
    }
  }
  cout << ans << endl;

  return 0;
}